package com.sfdk.pools
{
    import flash.media.Sound;
    import flash.utils.Dictionary;

    import org.as3wavsound.WavSound;

    public class WaveSoundPool
    {
        private static var _instance:WaveSoundPool;

        private var _pool:Dictionary;
        private var _totalSize:int;

        public function WaveSoundPool() {
            _pool = new Dictionary();
            _totalSize = 0;
            _instance = this;
        }

        public static function get instance():WaveSoundPool {
            return _instance;
        }

        public static function getFromPool(name:String):WavSound {
            return _instance.getFromPool(name);
        }

        public function addToPool(sound:WavSound, name:String):int {
            if (_pool[name] != null)
                return -1;

            _pool[name] = sound;
            return 1;
        }

        public function removeFromPool(name:String):void {
            _pool[name] = null;
        }

        public function getFromPool(name:String):WavSound {
            var sound:WavSound = _pool[name] as WavSound;
            return sound;
        }

        public function isInPool(name:String):Boolean {
            return (_pool[name] != null);
        }
    }
}